<template>
  <el-dialog title="根盒子设置" :visible.sync="visible" width="30%" :before-close="handleClose">
    <el-form :model="form">
      <el-form-item label="内边距" :label-width="formLabelWidth">
        <el-input v-model="form.padding" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="生成方式" :label-width="formLabelWidth">
        <el-select v-model="form.creatType" placeholder="请选择分割OR填充">
          <el-option label="分割" value="split"></el-option>
          <el-option label="填充" value="add"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="生成方向" :label-width="formLabelWidth">
        <el-select v-model="form.direction" placeholder="请选择生成方向">
          <el-option label="纵向" value="column"></el-option>
          <el-option label="横向" value="row"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="模块数量" :label-width="formLabelWidth">
        <el-input v-model.number="form.quantity" :min="2" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="hideCancel">取 消</el-button>
      <el-button type="primary" @click="hideConfirm(form)">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  name: "set-index",
  props: {
    // 显示隐藏
    visible: {
      type: Boolean,
      default: false
    },
    row: {
      type: Object,
      default: () => {
        return {}
      }
    },
    /**
     * 隐藏取消按钮
     */
    hideCancel: {
      type: Function,
      default: () => { }
    },
    /**
     * 隐藏确认按钮
     */
    hideConfirm: {
      type: Function,
      default: () => { }
    },
  },
  watch: {
    row: {
      handler(newVal, oldVal) {
        this.form = { ...newVal.setting }
      },
      deep: true,
    },
  },
  data() {
    return {
      form: {
        padding: '',
        creatType: 'split',
        direction: 'column',
        quantity: 2,
      },
      formLabelWidth: '120px'
    };
  },
  methods: {
    handleClose() {
      this.$confirm('确认关闭？')
        .then(_ => {
          this.hideCancel()
        })
        .catch(_ => { });
    },
  }
};
</script>
<style scoped>
</style>
